package cn.iocoder.yudao.module.book.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.book.controller.app.vo.AppBookShelfCatalogueRespVO;
import cn.iocoder.yudao.module.book.controller.app.vo.AppBookShelfRespVO;
import cn.iocoder.yudao.module.book.dal.dataobject.bookshelfcatalogue.BookShelfCatalogueDO;
import cn.iocoder.yudao.module.book.service.app.AppBookShelfCatalogueService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController
@RequestMapping("/bookShelfCategory")
public class AppBookShelfCategoryController {


    @Resource
    private AppBookShelfCatalogueService appBookShelfCatalogueService;

    @GetMapping("/all/{type}")
    @Operation(summary = "查询所有目录")
    public CommonResult<List<AppBookShelfCatalogueRespVO>> getBookShelfAllList(@PathVariable Long type) {
        List<BookShelfCatalogueDO> bookShelfAllList = appBookShelfCatalogueService.getBookShelfAllList(type);
        return success(BeanUtils.toBean(bookShelfAllList, AppBookShelfCatalogueRespVO.class));
    }


    @GetMapping("/getBookShelf")
    @Operation(summary = "查询目录下的绘本集")
    public CommonResult<List<AppBookShelfRespVO>> getBookShelf(
        @RequestParam String type, @RequestParam(required = false) Long id) {
        List<AppBookShelfRespVO> vos = appBookShelfCatalogueService.getBookShelf(type, id);
        return success(vos);
    }
}
